<template>
	<view class="container">
		<view class="total ">团队总数：{{member.team_num}}</view>
<!--		<view class="total">门店总数：{{member.store_num}}</view>-->
		<view class='nav'>
			<view :class='current==1?"font-color":""' class="nav_unit" id='1' v-on:click='operation'>一级({{lev_one}})</view>
			<view :class='current==2?"font-color":""' class="nav_unit" id='2' v-on:click='operation'>二级({{lev_two}})</view>
		</view>
		<view class="content" v-show="current==1">
			<view class="none" v-if="result[0].length==0">没有团队成员</view>
			<view class="member" v-for="(item,index) in result[0]" :key="index" v-else>
				<image :src="static+'/logo.png'" v-if="item.img.length<10"></image>
				<image :src="item.img" v-else></image>
				<view class="member_con">
					<view class="nickname" v-if="item.nickname!='0'">{{item.nickname}}</view>
					<view class="nickname" v-else>谷牧之道会员</view>
					<view class="phone">{{item.phone}}</view>
					<view class="register">{{item.datetime}}</view>
				</view>
				<view class="member_total">
					<!-- <view class="price">{{item.team_achievement}}</view> -->
					<view class="number">{{item.team_num}}人</view>
<!--					<view class="number" v-if="item.store_number==0">无门店</view>-->
<!--					<view class="number" v-else>{{item.store_number}}个门店</view>-->
				</view>
			</view>
		</view>
		<view class="content" v-show="current==2">
			<view class="none" v-if="result[1].length==0">没有团队成员</view>
			<view class="member" v-for="(item,index) in result[1]" :key="index" v-else>
				<image :src="static+'/logo.png'" v-if="item.img.length<10 "></image>
				<image :src="item.img" v-else></image>
				<view class="member_con">
					<view class="nickname" v-if="item.nickname!='0'">{{item.nickname}}</view>
					<view class="nickname" v-else>谷牧之道会员</view>
					<view class="nickname">{{item.upinfo.nickname}}</view>
					<view class="phone">{{item.phone}}</view>
					<view class="register">{{item.datetime}}</view>
				</view>
				<view class="member_total">
					<!-- <view class="price">{{item.team_achievement}}</view> -->
					<view class="number">{{item.team_num}}人</view>
<!--					<view class="number" v-if="item.store_number==0">无门店</view>-->
<!--					<view class="number" v-else>{{item.store_number}}个门店</view>-->
				</view>
			</view>
		</view>
	</view>
</template>
<style>
	page{background: #F4F4F4;}
	.container{width:100%;}
	.cash_submit{background: #3de9c7;border-radius: 10upx;text-align: center;width:25%;font-size: 26upx;color: #FFFFFF;height: 55upx;line-height: 55upx;}
	.nav{width:100%;height: 80upx;background-color:#FFFFFF; display: flex;align-items: center;justify-content: flex-start;flex-wrap: nowrap;}
	.nav_unit{width: 50%;height: 80upx;line-height: 80upx;  font-size: 28upx;text-align: center;}
	.font-color{color: #3de9c7;border-bottom:2px solid #3de9c7;}
	.content{width: 100%;}
	
	.total{width:100%;line-height:70upx;text-align: center;font-size: 30upx;background: #FFFFFF;}
	.member{width:92%;margin: 10upx 3%;padding: 10upx 1%;background: #FFFFFF;border-radius:10upx;display: flex;justify-content: flex-start;align-items: center;}
	.member image{width:80upx;height:80upx;border-radius:40upx;background: #3DE9C7;margin-right: 20upx;}
	.member_con{display: flex;flex-direction: column;justify-content: space-between;align-items: flex-start;width:58%}
	.nickname,.phone,.register{font-size: 28upx;line-height: 40upx;}
	.phone{color: #CCCCCC;}
	.member_total{width: 30%;height: 120upx;display: flex;justify-content: center;align-items:flex-end;flex-direction: column;padding-right: 2%;}
	.price{font-size:30upx;width:100%;text-align: right;}
	.none{width:100%;text-align: center;line-height: 80upx;font-size: 28upx;background: #FFFFFF;}
	.number{color: #ff1844;font-size: 32upx;width:100%;text-align: right;}
</style>
<script>
	export default {
		data() {
			return {
				current: 1,
				pic_h:'',
				result:[[],[]],
				start:[0,0],
				member:[],
				submit_status:1,
				refresh_status:0,
				lev_one:0,
				lev_two:0,
				url: getApp().globalData.url,
				static:getApp().globalData.static
			}
		},
		onLoad(e) {
			var res = uni.getSystemInfoSync();
			var w = res.windowWidth;
			this.pic_h = w*0.92*0.2+"px";
			this.initialize();
		},
		onPullDownRefresh() {
			this.refresh_status = 1;
			this.initialize();
		},
		onReachBottom:function()
		{
			this.initialize();
		},
		methods: {
			initialize:function()
			{
				var that = this;
				var st = this.current-1;
				var member_id = uni.getStorageSync("member_id");
				// var member_id = 168981;
				// var member_id = 169006;
				
				
				uni.request({
					url: this.url+'/wechat_member_team', 
					data: {member_id:member_id,type:this.current,start:this.start[st]},
					header: {'Content-Type': 'application/json'},
					success: (res) => {
						that.member = res.data.my_info[0];
						that.lev_one = res.data.lev_one;
						that.lev_two = res.data.lev_two;
						console.log(res);
						if(res.data.status==1)
						{
							that.start[st] += 10;
							for(var k=0;k<res.data.team_people_list.length;k++)
							{
								that.result[st].push(res.data.team_people_list[k]);
							}
						}
						if(that.refresh_status==1)
						{
							that.refresh_status = 0;
							uni.stopPullDownRefresh();
						}
					}
				});
			},
			operation:function(e)
			{
				var id = e.currentTarget.id;
				console.log(id);
				this.current = parseInt(id);
				this.initialize();
			}
		}
	}
</script>


